package sdfi.lee.SetFileToDB;

import java.util.Enumeration;

import javax.jms.Connection;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;

import sdfi.lee.JMS.ConnectionFactory;

public class SetFileToDB {
	public static void main(String agr[])
	{
		Connection con=ConnectionFactory.getCon();
		Session session=null;
		try
		{
			con.start();
		session=con.createSession(false, Session.AUTO_ACKNOWLEDGE);
		
		MessageConsumer consumer=session.createConsumer(session.createQueue("ans"));
		consumer.setMessageListener(new MessageListener(){

			@Override
			public void onMessage(Message arg0) {
				// TODO Auto-generated method stub
				MapMessage mapmsg=(MapMessage)arg0;
				try
				{
					Enumeration enumeration=mapmsg.getMapNames();
				
					while(enumeration.hasMoreElements())
					{
						System.out.println(mapmsg.getString(enumeration.nextElement().toString()));
					}
				}
				catch(Exception ee)
				{
					ee.printStackTrace();
				}
			}
			
		});
		}
		catch(Exception ee)
		{
			ee.printStackTrace();
		}
	}
}
